package com.mrx.pvzcommunity.dao;

import com.mrx.pvzcommunity.model.pvz.Plant;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 植物相关操作
 */
@Repository
public interface PlantDao {

    @Select("SELECT * FROM plants WHERE name = #{name}")
    List<Plant> findPlantByName(@Param("name") String name);

    @Select("SELECT * FROM plants WHERE disposable = #{dp}")
    List<Plant> findPlantByDisposable(@Param("dp") String dp);

    @Select("SELECT * FROM plants WHERE env = #{env}")
    List<Plant> findPlantByEnv(@Param("env") String env);

    @Select("SELECT * FROM plants WHERE env = #{env} AND disposable = #{dp}")
    List<Plant> findPlantByEnvAndDp(@Param("env") String env, @Param("dp") String dp);

    @Select("SELECT * FROM plants")
    List<Plant> getAllPlants();

    @Select("SELECT img FROM plants WHERE pid = #{pid}")
    String getPlantImgById(@Param("pid") String pid);
}
